package cn.com.shbs.Service.EmployeeInfoService;

import cn.com.shbs.Dao.EmployeeInfoDao.EmployeeInfoDao;
import cn.com.shbs.Service.UserInfoService.IUserInfoService;
import cn.com.shbs.model.EmployeeInformation;
import cn.com.shbs.model.LoginUser;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.ArrayList;
import java.util.List;

@Service
public class EmployeeInfoServiceImpl implements EmployeeInfoService {

    static Logger logger = LoggerFactory.getLogger(EmployeeInfoServiceImpl.class);

    @Autowired
    IUserInfoService userinfoservice;
    @Autowired
    EmployeeInfoService employeeInfoService;
    @Autowired
    EmployeeInfoDao employeeInfoDao;


    @Override
    @Transactional(rollbackFor = Exception.class)
    public void addemployeeinfo(LoginUser userInfo,EmployeeInformation employeeInformation) throws Exception {
        try{
        // 添加用户表
            userinfoservice.Modfiysysuser(userInfo);
            employeeInfoDao.addemployeeinfo(employeeInformation);
        }catch (Exception e){
            logger.error("EmployeeInfoServiceImpl.addemployeeinfo()", e);
            throw e;
        }
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void editemployeeinfo(EmployeeInformation employeeInformation) throws Exception {
        try{
            employeeInfoDao.editemployeeinfo(employeeInformation);
        }catch (Exception e){
            logger.error("EmployeeInfoServiceImpl.editemployeeinfo()", e);
            throw e;
        }
    }

}
